﻿using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Hx.Components.Models;

namespace Hx.Components
{
    public partial class Header
    {
        public Header()
        {
            InitializeComponent();
        }

        private void Min_Click(object sender, MouseButtonEventArgs e)
        {
            foreach (Window window in Application.Current.Windows)
                window.Hide();
        }

        private void Max_Click(object sender, MouseButtonEventArgs e)
        {
            var window = Application.Current.Windows[0];
            if (window != null)
            {
                window.WindowState = window.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
            }
        }

        private void Close_Click(object sender, MouseButtonEventArgs e)
        {
            foreach (Window window in Application.Current.Windows)
                window.Close();
        }

        public void SetAuthor(AuthorModel author)
        {
            if (!String.IsNullOrEmpty(author.Face))
                AuthorFace.ImageSource = new BitmapImage(new Uri(author.Face, UriKind.RelativeOrAbsolute));

            NickName.Text = author.AuthorName;
            Signature.Text = author.Signature;
        }
    }
}